package com.lagou.filter;

import com.lagou.po.ServiceMethodInfo;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class RemoveDateThread implements Runnable {
    private Map<String, List<ServiceMethodInfo>> methodTimes;
    public RemoveDateThread(Map<String, List<ServiceMethodInfo>> methodTimes){
        this.methodTimes=methodTimes;
    }
    @Override
    public void run() {
        System.out.println("调用删除过期的数据开始。。。。。");
        for(Map.Entry<String,List<ServiceMethodInfo>>mapEntry:methodTimes.entrySet()){
            List<ServiceMethodInfo>methodInfoList=mapEntry.getValue();
            Iterator<ServiceMethodInfo> iterator=methodInfoList.iterator();
            Long removeConnect=System.currentTimeMillis()-60000;
            while(iterator.hasNext()){
                if(iterator.next().getEndTime()<removeConnect){
                    iterator.remove();
                }
            }
        }
        System.out.println("调用删除过期的数据结束。。。。。");
    }
}
